package gen.tools.req;

import gen.tools.Widgets;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class IsReqDuplicated extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    public IsReqDuplicated() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request,response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		final Widgets wid = new Widgets();
		request.setCharacterEncoding( wid.UIcodeSet );
		response.setContentType("application/json");
		response.setCharacterEncoding( wid.UIcodeSet );
		
		final String reqSID = request.getParameter("reqSID");
		final String reqDesc = request.getParameter("reqDesc");
		
		int res=0;
		
		try {
			res = wid.isReqExisted(reqSID, reqDesc);
		} catch (Exception e) {
			wid.errLog(e);
		}
		
		response.getWriter().write( String.valueOf( res ) );
	}

}
